package com.nineclock.attendance.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nineclock.attendance.dto.AtHolidayRuleDto;
import com.nineclock.attendance.mapper.AtHolidayRuleMapper;
import com.nineclock.attendance.pojo.AtHolidayRule;
import com.nineclock.attendance.service.AtHolidayRuleService;
import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.common.filter.CurrentUserHolder;
import com.nineclock.common.utils.BeanHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("rule")
@Api(value = "考勤组管理接口", tags = "考勤服务")
public class AtHolidayRuleController {

  @Autowired
  private AtHolidayRuleService atHolidayRuleService;

    /**
     * 假期管理*/
    @GetMapping("holiday")
    @ApiOperation("假期管理")
    public Result<PageResult<AtHolidayRuleDto>> selectHoliday(@RequestParam(defaultValue = "1") Integer page,
                                                              @RequestParam(defaultValue = "10") Integer pageSize){

           PageResult<AtHolidayRuleDto> atHolidayRuleDtoPageResult= atHolidayRuleService.selectHoliday(page,pageSize);
           return Result.success(atHolidayRuleDtoPageResult);
    }
    /**
     * 假期删除*/
    @DeleteMapping("holiday/{id}")
    @ApiOperation("假期删除")
    public Result deleteById(@PathVariable Long id){
        atHolidayRuleService.deleteById(id);
        return Result.success();
    }
    /**
     * 修改假期*/
    @PutMapping("holiday/{id}")
    @ApiOperation("修改假期")
    public Result updateHoliday(@PathVariable Long id,@RequestBody AtHolidayRuleDto atHolidayRuleDto){
        atHolidayRuleService.updateHoliday(id,atHolidayRuleDto);
        return Result.success();
    }

    /**
     * 新增假期*/
    @PostMapping("holiday")
    @ApiOperation("修改假期")
    public Result addHoliday(@RequestBody AtHolidayRuleDto atHolidayRuleDto){
        atHolidayRuleService.addHoliday(atHolidayRuleDto);
        return Result.success();
    }
}
